package io.adrainty.bolee.security.feign.impl;

import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.framework.commons.utils.ResultDTOUtil;
import io.adrainty.bolee.security.feign.ICompanyFeign;
import io.adrainty.bolee.security.models.entity.CompanyEntity;
import io.adrainty.bolee.security.service.ICompanyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>CompanyFeignImpl</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description CompanyFeignImpl
 * @since 2025/8/1 14:16:40
 */

@Slf4j
@RestController
@Tag(name = "企业接口")
@RequestMapping("/company-feign")
public class CompanyFeignImpl implements ICompanyFeign {

    @Resource
    private ICompanyService companyService;

    @Override
    @Operation(summary = "刷新企业缓存")
    @GetMapping("/refreshCompanyWebsiteCache")
    public ResultDTO<Boolean> refreshCompanyWebsiteCache() {
        boolean result = companyService.refreshCompanyWebsiteCache();
        return ResultDTOUtil.success(result);
    }

    @Override
    @Operation(summary = "获取企业信息")
    @GetMapping("/findCompanyEntity/{companyNo}")
    public ResultDTO<CompanyEntity> findCompanyEntity(@PathVariable("companyNo") String companyNo) {
        CompanyEntity companyEntity = companyService.findCompanyEntity(companyNo);
        return ResultDTOUtil.success(companyEntity);
    }

}
